<?php $this->include('layouts/default/list_header', array_merge($site, ['question_title' => $question['title'], 'tag' => $data['tags'][array_key_first($data['tags'])]])) ?>
<header class="">
  <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container">
      <div class="navbar-header page-scroll">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          <span class="sr-only"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="/" title="<?php echo $site['title']; ?>"><?php echo $site['title']; ?></a>
      </div>
      <div class="collapse navbar-collapse" id="navbar">
        <form class="navbar-form navbar-right" action="/search" onsubmit="return checkForm(this)">
          <div class="input-group">
            <input type="text" class="form-control" placeholder="Search for..." name="keywords" value="<?php echo $keywords ?? '' ?>">
            <span class="input-group-btn">
              <button class="btn btn-default" type="submit">搜索</button>
            </span>
          </div>
        </form>
      </div>
    </div>
  </nav>
</header>

<div class="container left-block hidden-xs">
  <div class="row">
    <div class="col-md-2">
      <div class="tag-list m-h bg-white">
        <?php
        $idx = 0;
        foreach ($data['tags'] as $tid => $tag) {
          if ($idx == 0) {
            echo '<a href="/tag/' . $tid . '" class="blod">' . $tag . '</a><div class="border-bottom m-h"></div>';
          } else {
            echo '<a href="/tag/' . $tid . '">' . $tag . '</a>';
          }
          $idx++;
        }
        ?>
      </div>
    </div>
  </div>
</div>
<div class="container mt-header">
  <div class="row">
    <div class="col-md-8 col-md-offset-2 border-left">
      <h3 class="border-bottom p-h m-h">
        <span class="border-circle">Q</span><?php echo $question['title']; ?>
      </h3>
      <div class="pre-line">
        <?php echo str_replace('< >', '',$question_content); ?>
      </div>
      <div class="text-right m-h p-h border-top">
        <span><?php echo $question['created_at'], '&nbsp;&nbsp;<span class="author">', $question['user'], '</span>'; ?></span>
      </div>

      <div class="mt-2">
        <ul class="comment-list">
          <?php
          echo preg_replace('/<a href="\/users\/(.*?)"/', '<a href="javascript:"', $question_comment);
          ?>
        </ul>
      </div>

      <div class="answer mt-2">
        <h3 class="border-bottom p-h m-h">
          <span class="border-circle">A</span>回答
        </h3>
        <ul class="answer-list">
          <?php
          foreach ($answer as $index => $item) {
            echo '<li><span class="number">' . ($index + 1) . '</span>' . str_replace(['“', '”', '<>'], '', $item['answer']) . '<div class="text-right p-h border-bottom">' . $item['created_at'] . '&nbsp;&nbsp;<span class="author">' . $item['user'] . '</span></div>';
            if (isset($answer_comment[$item['answer_id']])) {
              echo '<ul class="answer-comment">', preg_replace('/<a href="\/users\/(.*?)"/', '<a href="javascript:"', $answer_comment[$item['answer_id']]), '</ul>';
            }
            echo '</li>';
          }
          ?>
        </ul>
      </div>
    </div>

    <!--TODO advertising-->
    <div class="col-md-2">
      <!--
      <div>
        <ul class="list-group">
          <li class="adv-box">
            <small class="adv-close">广告×</small>
            <a href="https://www.baidu.com">
              <img
                src=""
                alt="adv" class="img-responsive">
            </a>
          </li>
        </ul>
      </div>
      -->
    </div>
  </div>
</div>

<?php $this->include('layouts/default/footer') ?>
